package 工具类测试;

import org.junit.Test;
import 图片相似度计算.ImageHistogram;
import 图片相似度计算.ImagePHash;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;

/**
 * Description
 *
 * @Author: SunAo
 * @Date: 2022/2/20 19:46
 */
public class 图片相似度计算测试 {

    private File file1 = new File("D:\\Temp\\002_2021-05-13_F3B3A9BF.jpeg");
    private File file2 = new File("D:\\Temp\\002_2020-01-22_A5610156.jpeg");

    @Test
    public void ImageHistogramTest() throws IOException {
        ImageHistogram image = new ImageHistogram();
        double result = image.match(file1,file2);
        System.out.println(result);
    }

    @Test
    public void ImagePHashTest() throws Exception {
        ImagePHash image = new ImagePHash();
        String hash1 = image.getHash(new FileInputStream(file1));
        String hash2 = image.getHash(new FileInputStream(file2));
        System.out.println("hash1:"+hash1);
        System.out.println("hash2:"+hash2);
        int result = image.distance(hash1,hash2);
        System.out.println(result);
    }

}
